﻿/*
作者：高彩红
时间：209-12-2
功能：互动交流列表显示
**/
var ModelId = "";
var Type = "";
var PageSize = 10;
var ArrList = new Array();
var page = 1;
var key = "";
var drops = "0";
function ShowMain() {
    page = request("page")
    if (page == undefined || page == "") {
        page = 1;
        GetNewsList(1, key, drops);
    }
    else {
        page = request("page");
        GetNewsList(page, key, drops);
    }

}

function SelectAll(id, name)//全选
{
    var checks = document.getElementsByTagName("input");
    for (var i = 0; i < checks.length; i++) {
        if (checks[i].name == name) {
            checks[i].checked = document.getElementById(id).checked;
        }
    }
};

function SelectIDs(name) {
    var checks = document.getElementsByTagName("input");
    var str = "";
    for (var i = 0; i < checks.length; i++) {
        if (checks[i].name == name && checks[i].checked) {
            str += checks[i].value + ",";
        }
    }
    return str;
};

//获取"信息列表"
function GetNewsList(page, t1, t2) {
    Type = request("name");
    if (key == undefined) {
        key = "";
    }
    indexpage = page;
    var url = encodeURI(SBasePath + '/action/GetNum.aspx');
    var pars = encodeURI("?PageIndex=" + page + "&PageSize=" + PageSize + "&type=" + Type + "&t1=" + t1 + "&t2=" + t2);
    var myAjax = new Ajax.Request(url, { method: 'get', parameters: pars, onComplete: sGetNewsList, onFailure: fGetNewsList });

}
//获取"栏目列表"成功
function sGetNewsList(o) {
    ArrList = Map_Num(o);
    ShowContent();

}

function fGetNewsList(o) {

}
//显示列表
function ShowContent() {
    var str = "";

    str += '<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">'
    str += '        <tr>';
    str += '            <td height="30">';
    str += '                <table width="100%" border="0" cellspacing="0" cellpadding="0">';
    str += '                    <tr>';
    str += '                        <td width="15" height="30">';
    str += '                            <img src="img/tab_03.gif" width="15" height="30" />';
    str += '                        </td>';
    str += '                        <td width="1101" background="img/tab_05.gif">';
    str += '                            <img src="img/311.gif" width="16" height="16" />';
    str += '                            <span class="title1">信息统计列表</span>';
    str += '                        </td>';
    str += '                        <td width="281" background="img/tab_05.gif">';
    str += '                            <table border="0" align="right" cellpadding="0" cellspacing="0">';
    str += '                                <tr>';
    str += '                                    <td width="60">';
    str += '                                        <table width="87%" border="0" cellpadding="0" cellspacing="0">';
    str += '                                            <tr>';
    str += '                                                <td>';
    str += '                                                    <div align="center">';
    //str += '                                                        <input id="ChkAll" type="checkbox" onclick=\'SelectAll("ChkAll","ChkAllValue")\' />';
    str += '                                                </td>';
    str += '                                                <td>';
    //str += '                                                    <div align="center" class="f_green">全选</div>';
    str += '                                                </td>';
    str += '                                            </tr>';
    str += '                                        </table>';
    str += '                                    </td>';
    str += '                                    <td width="60">';
    str += '                                        <table width="90%" border="0" cellpadding="0" cellspacing="0">';
    str += '                                            <tr>';
    str += '                                                <td>';
    str += '                                                    <div align="center">';
    //str += '                                                        <img src="img/001.gif" width="14" height="14" /></div>';
    str += '                                                </td>';
    str += '                                                <td>';
    //str += '                                                    <div align="center" class="f_green"><a style="cursor: hand" onclick="javascript:ModelAdd()">新增</a></div>';
    str += '                                                </td>';
    str += '                                            </tr>';
    str += '                                        </table>';
    str += '                                    </td>';
    str += '                                    <td width="52">';
    str += '                                        <table width="88%" border="0" cellpadding="0" cellspacing="0">';
    str += '                                            <tr>';
    str += '                                                <td>';
    str += '                                                    <div align="center">';
    //str += '                                                        <img src="img/083.gif" width="14" height="14" /></div>';
    str += '                                                </td>';
    str += '                                                <td>';
    //str += '                                                    <div align="center" class="f_green"><a style="cursor: hand" onclick="javascript:DelModels(\'ChkAllValue\')">删除</a></div>';
    str += '                                                </td>';
    str += '                                            </tr>';
    str += '                                        </table>';
    str += '                                    </td>';
    str += '                                </tr>';
    str += '                            </table>';
    str += '                        </td>';
    str += '                        <td width="14">';
    str += '                            <img src="img/tab_07.gif" width="14" height="30" />';
    str += '                        </td>';
    str += '                    </tr>';
    str += '                </table>';
    str += '            </td>';
    str += '        </tr>';
    //***********************************查询
    str += '<form id="newlist">';
    str += '<tr>';
    str += '    <td valign="top" ><table width="100%" border="0" cellspacing="0" cellpadding="0">';
    str += '<tr>';
    str += '        <td width="9" class="tab12"></td>';
    str += '<td bgcolor="#f3ffe3" ><table border="0" cellpadding="0" cellspacing="0" ';
    str += 'width="99%" class="k_green" align="center">';
    str += '        <tr>';
//    str += '          <td width="90" align="center"  height="25"  >搜索条件：</td>';
//    str += '          <td width="132">';
//    str += '<select name="cid" style="width:120px">';
//    str += '<option value="0">选择栏目...</option>';
//    str += '<option value="1">内容</option>';
//    str += '<option value="2">部门</option>';
//    str += '</select>';
//    str += '        </td>';
    str += '        <td width="60">';
    str += '          统计时间：        </td>';
    str += '        <td width="360">';
    str += '          	<input type="text" name="kstime" onFocus="var d5222=$dp.$(\'jstime\');WdatePicker({onpicked:function(){d5222.focus();},maxDate:d5222.value})" class="k_green" /> 至 <input type="text" name="jstime" onFocus="var d5222=$dp.$(\'kstime\');WdatePicker({minDate:d5222.value})" class="k_green" />';
    str += '        </td>';
    str += '        <td><input type="button" name="Submit" onclick="search(kstime.value,jstime.value);" value="查询" class="bg_w"';
    str += 'style="border:height:22px;width:55px; border:solid 1px #cadcb2;"/>';
    str += '        </td>';
    str += '       </tr>';
    str += '      </table></td>';
    str += '        <td width="8" class="tab16"></td>';
    str += '      </tr>';
    str += '    </table></td>';
    str += '  </tr>';
    str += '</form>';
    //*************************************************
    str += '        <tr>';
    str += '            <td>';
    str += '                <table width="100%" border="0" cellspacing="0" cellpadding="0">';
    str += '                    <tr>';
    str += '                        <td width="9" background="img/tab_12.gif"> &nbsp;</td>';
    str += '                        <td bgcolor="#f3ffe3">';
    str += '                            <table width="99%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#c0de98">';
    str += '                                <tr>';
    str += '                                    <td height="26" background="img/tab_14.gif">';
    str += '                                        <div align="center" class="f_green"></div> ';
    str += '                                    </td>';
    for (var i = 0; i < ArrList.length; i++) {

        if (ArrList[i].ModelName != "") {
            str += '                                    <td height="26" background="img/tab_14.gif">';
            str += '                                        <div align="center" class="f_green">' + ArrList[i].ModelName + '</div> ';
            str += '                                    </td>';
        }
       
    }
    str += '                                </tr>';
    str += '                                <tr class="bg_w" onmouseout="this.className=\'bg_w\'" onmouseover="this.className=\'bg_g\'">';
    
    str += '                                    <td height="18">';
    str += '                                        <div align="center">信息条数';
    //str += '                                            <input name="ChkAllValue" type="checkbox" value="' + ArrList[i].ModelId + '" />';
    str += '                                        </div>';
    str += '                                    </td>';
    for (var i = 0; i < ArrList.length; i++) {

        if (ArrList[i].ModelName != "") {
            str += '                                    <td height="18">';
            str += '                                        <div align="center">' + ArrList[i].Sl + '</div>';
            str += '                                    </td>';
        }
       
    }
    str += '                                </tr>';
    str += '                            </table>';
    str += '                        </td>';
    str += '                        <td width="9" background="img/tab_16.gif">&nbsp;</td>';
    str += '                    </tr>';
    str += '                </table>';
    str += '            </td>';
    str += '        </tr>';

    str += '        <tr>';
    str += '            <td height="29">';
    str += '                <table width="100%" border="0" cellspacing="0" cellpadding="0">';
    str += '                    <tr>';
    str += '                        <td width="15" height="29">';
    str += '                            <img src="img/tab_20.gif" width="15" height="29" />';
    str += '                        </td>';
    str += '                        <td background="img/tab_21.gif">';
    str += '                            <table width="100%" border="0" cellspacing="0" cellpadding="0">';
    str += '                                <tr>';
    str += '                                    <td width="25%" height="29" nowrap="nowrap">&nbsp;';
    //str += '                                        <span class="f_green">共' + Total + '条记录, 当前第' + PageIndex + '/' + PageTotal + '页,每页' + PageSize + '条纪录</span>';
    str += '                                    </td>';
    str += '                                    <td width="75%" valign="top">';
    str += '                                        <div align="right">&nbsp;';
    str += '                                        </div>';
    str += '                                    </td>';
    str += '                                </tr>';

    str += '                            </table>';
    str += '                        </td>';
    str += '                        <td width="14">';
    str += '                            <img src="img/tab_22.gif" width="14" height="29" />';
    str += '                        </td>';
    str += '                    </tr>';

    str += '                </table>';
    str += '            </td>';
    str += '        </tr>';
    str += '    </table>';
    $("Top").innerHTML = str;
}
//标题去除html标记
function CutChar(titles) {
    var tmp = "";
    var tmp1 = "";
    tmp = titles.replace(/<(\w+)\s[^>]*>/g, "<$1>");
    tmp1 = tmp.replace(/<[^>]*>/g, '');
    return tmp1;
}

//检索函数
function search(t1, t2) {
    if (CheckAddForm()) {
        GetNewsList(page, t1, t2);
    }
}


//----------------------修改审核状态--------------------------------//
function ShenHe(id, key) {
    if (ConfrimDlg(GetMsg("1"), "aa('" + id + "','" + key + "')")) {
    }
}
function aa(id, key) {
    var url = encodeURI(SBasePath + '/action/Hdjl/ShenHe.aspx');
    var pars = encodeURI("?idstr=" + id + "&key=" + key + "&page=" + indexpage);
    var myAjax = new Ajax.Request(url, { method: 'get', parameters: pars, onComplete: sGetShenHeList, onFailure: fGetShenHeList });
}
//获取"信息列表"成功
function sGetShenHeList(o) {

    var root = o.responseXML.documentElement;
    var flag = GetXmlData(root, "Value");
    page = GetXmlData(root, "Page");
    if (flag == "true") {
        window.top.frames["Content"].location.href = SBasePath + '/htm/Hdjl/hdjlList.htm?page=' + page + '&name=' + Type + '&key=' + key;
    }
    else {
        MsgDlg(GetMsg("0"));
    }

}
function fGetShenHeList(o) {

}
//--------------------修改审核状态-------------------------------//

//回复信息
function HuiFu(id) {
    location.href = SBasePath + "/htm/Hdjl/HdjlEdit.htm?id=" + id;
}
//---------------------------确认删除------------------------------------------------//
function DelNews(Id) {
    if (Id == "ChkAllValue") {
        var idstr = SelectIDs(Id);
        if (idstr.length == 0) {
            MsgDlg(GetMsg("10"));
        }
        else {
            ConfrimDlg(GetMsg("2"), "DelNew('" + idstr + "')");
        }
    } else {
        ConfrimDlg(GetMsg("2"), "DelNew('" + Id + "')");
    }
}

var DelNew = function(Id)//删除
{

    var url = encodeURI(SBasePath + '/action/Hdjl/Del.aspx');
    var pars = encodeURI('?idstr=' + Id + "&page=" + indexpage);
    var myAjax = new Ajax.Request(url, { method: 'get', parameters: pars, onComplete: sDelNews, onFailure: fDelNews });

};

//操作成功
function sDelNews(o) {
    var root = o.responseXML.documentElement;
    var flag = GetXmlData(root, "Value");
    page = GetXmlData(root, "Page");
    if (flag == "true") {
        window.top.frames["Content"].location.href = SBasePath + '/htm/Hdjl/hdjlList.htm?page=' + page + '&name=' + Type + '&key=' + key;
    }
    else {
        MsgDlg(GetMsg("0"));
    }
}

//操作失败
function fDelNews(o) {
}
//---------------------------确认删除------------------------------------------------//

function GetNewsListPage() {
    if (checkPage()) {
        if (key == undefined) {
            key = "";
        }
        var url = encodeURI(SBasePath + '/action/Hdjl/HdjlList.aspx');
        var pars = encodeURI("?PageIndex=" + document.getElementById("page").value + "&PageSize=" + PageSize + "&type=" + Type + "&key=" + key);
        var myAjax = new Ajax.Request(url, { method: 'get', parameters: pars, onComplete: sGetNewsListPage, onFailure: fGetNewsListPage });
    }
}

function sGetNewsListPage(o) {
    ArrList = MapHdjlList(o);
    Total = MapPage(o, "RecordCount");
    PageIndex = MapPage(o, "PageIndex");
    PageTotal = Math.ceil(Total / PageSize)
    if (document.getElementById("page").value > PageTotal) {
        MsgDlg('不能超出范围页数！');
        document.getElementById("page").value = "";
        return false;
    }
    ShowContent();
}

function fGetNewsListPage() {

}

var checkPage = function() {
    var page = document.getElementById("page").value;
    if (isNaN(page) || page == "") {
        MsgDlg('请输入页数！');
        return false;
    }
    return true;
}


var CheckAddForm = function() {

    var fobj = $("newlist");

    if (fobj.kstime.value == "") {
        //0所有类型
        alert("请选择时间段");
        fobj.kstime.focus();
        return false;
    }
    if (fobj.jstime.value == "") {
        //0所有类型
        alert("请选择时间段");
        fobj.jstime.focus();
        return false;
    }
    return true;
};
